﻿@{
    Bundle("jquery_validate");
    string defaultTitle = String.Empty;
    string defaultText = String.Empty;
    switch((string)Model.Type)
    {
        case "blogpost":
            var t_post = (Model.Target.Translations as IEnumerable<dynamic>)
                .SingleOrDefault(x => JDM.Int32(x.Language.EntityID) ==
                    JDM.Int32(Svc.Localization.Language.EntityID));
            defaultTitle = T(Res.In("Common").Of("Expr").Name("Re"),
                t_post != null
                    ? JDM.String(t_post.Title)
                    : String.Empty);
            break;
    }
}

<script type="text/javascript">
    jQuery(document).ready(function () {
        jQuery('@ID("#form")').validate({
            rules: {
                title: {
                    required: true
                },
                text: {
                    required: true
                }
            }
        });
    });
</script>
<form id="@ID("form")" class="common-form" action="@Url.Action(Loc.Act("Comment").Localized())" method="post">
    <input type="hidden" name="tgtID" value="@JDM.Int32(Model.Target.EntityID)" />
    <input type="hidden" name="tgtType" value="@Model.Type" />
    <table>
        <tr>
            <td>
                <label>@T(Res.Name("Title"))</label>
            </td>
            <td>
            @{
                
                <input type="text" name="title" maxlength="1000" value="@defaultTitle" />
            }
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Text"))</label>
            </td>
            <td>
                <textarea name="text" maxlength="4000">@defaultText</textarea>
            </td>
        </tr>
    </table>
    <ul class="bar toolbar">
        <li><button class="button" type="submit">@T(Res.In("Common").Of("Act").Name("Submit"))</button></li>
    </ul>
</form>